#include <iostream>
#include <string>
#include <unordered_set>
#include <vector>
using namespace std;

const int kMaxN = 8;
const int kMaxM = 8;

int n, m, T;
vector<string> g;
int cnt;
int end_x, end_y;
int start_x, start_y;

void Pre(int n, int m) {
  cnt = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (g[i][j] == '.') {
        cnt++;
      }
      if (g[i][j] == 'D') {
        end_x = i;
        end_y = j;
      }
      if (g[i][j] == 'S') {
        start_x = i;
        start_y = j;
      }
    }
  }
}

int dir[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};

bool Check(int x, int y) {
  return x >= 0 && x < n && y >= 0 && y < m && g[x][y] == '.';
}

bool DFS(int now_x, int now_y, int dep) {
  if (abs(end_x - now_x) + abs(end_y - now_y) + dep > T) {
    return false;
  }
  if (dep + 1 == T) {
    return true;
  }
  for (int i = 0; i < 4; i++) {
    int next_x = now_x + dir[i][0], next_y = now_y + dir[i][1];
    if (Check(next_x, next_y)) {
      g[next_x][next_y] = '$';
      if (DFS(next_x, next_y, dep + 1)) {
        return true;
      }
      g[next_x][next_y] = '.';
    }
  }
  return false;
}

int main() {
  while (1) {
    cin >> n >> m >> T;

    if (n == 0 && m == 0 && T == 0) {
      break;
    }
    g.clear();
    g.resize(n);
    for (int i = 0; i < n; i++) {
      cin >> g[i];
    }
    Pre(n, m);
    if ((abs(start_x - end_x) + abs(start_y - end_y) + T) & 1) {
      cout << "NO" << endl;
    } else if (cnt + 1 >= T && DFS(start_x, start_y, 0)) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
  return 0;
}